package cn.com.homeyoda.aimate.aihealth.ui.health.adapter;

import android.content.Context;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import cn.com.homeyoda.aimate.aihealth.R;
import cn.com.homeyoda.aimate.aihealth.bean.SportTitleBean;

import java.util.List;

/**
 * Created By 刘纯贵
 * Created Time 2020/4/30
 */
public class SportTitleAdapter extends BaseQuickAdapter<SportTitleBean, BaseViewHolder> {

    private int selectPos = 5;
    private Context mContext;
    public SportTitleAdapter(int layoutResId, @Nullable List<SportTitleBean> data, Context context) {
        super(layoutResId, data);
        mContext = context;
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, SportTitleBean item) {

    }

    @Override
    public void onBindViewHolder(BaseViewHolder holder, int position) {
        super.onBindViewHolder(holder, position);
        holder.setText(R.id.week,getData().get(position).getWeek());
        holder.setText(R.id.date,getData().get(position).getDate());

        if(selectPos == position){
            holder.setTextColor(R.id.week,mContext.getResources().getColor(R.color.white));
            holder.setBackgroundRes(R.id.date,R.drawable.shap_button_white_bg60);
            holder.setBackgroundRes(R.id.rel,R.drawable.shap_button_bg60);
        }else{
            holder.setTextColor(R.id.week,mContext.getResources().getColor(R.color.black));
            holder.setBackgroundRes(R.id.date,R.color.transparent);
            holder.setBackgroundRes(R.id.rel,R.color.transparent);
        }
    }

    public void setPos(int pos){
        selectPos = pos;
        notifyDataSetChanged();
    }

    @Override
    public void setNewData(@Nullable List<SportTitleBean> data) {
        super.setNewData(data);
    }
}
